package cn.changeforyou.web.blog.po;

import cn.changeforyou.web.nutz.common.valid.ValidConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Table;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author aqian666
 */
@Data
@Table("blog_article")
@EqualsAndHashCode(callSuper = false)
public class Article implements Serializable {

    private static final long serialVersionUID = 1L;

    //    @FieldKey(type = LDType.IntPoint)
    @NotNull(groups = ValidConstant.Update.class)
    @Id
    private Integer id;

    /**
     * 文章标题
     */
//    @FieldKey(type = LDType.TextField,highlight = true)
    @NotEmpty
    private String articleName;

    /**
     * 文章封面
     */
    private String articleHeadPic;

    /**
     * 文章标签
     */
//    @FieldKey(type = LDType.StringField)
    @NotEmpty
    private String articleTag;

    /**
     * 文章备注
     */
//    @FieldKey(type = LDType.TextField)
    private String articleRemark;

    /**
     * 文章阅读量
     */
//    @FieldKey(type = LDType.IntPoint)
    private Integer articleReadCount;

    /**
     * 文章审核状态
     */
//    @FieldKey(type = LDType.IntPoint)
    private Integer articleState;

    /**
     * 文章内容
     */
//    @FieldKey(type = LDType.TextField,highlight = true)
    @NotEmpty
    private String articleContent;

    /**
     * 文章作者id
     */
//    @FieldKey(type = LDType.IntPoint)
    private Integer managerId;

    /**
     * 作者名称
     */
//    @FieldKey(type = LDType.StringField)
    private String managerName;

    /**
     * 创建时间
     */
//    @FieldKey(type = LDType.DateField)
    private LocalDateTime createTime;

    //    @FieldKey(type = LDType.IntPoint)
    @NotEmpty
    private String articleType;

    //    @FieldKey(type = LDType.IntPoint)
    private Integer articleStarNum;

    //    @TableField("articleConNum")
    private Integer articleConNum;

    @NotEmpty
    private String articleMdContent;

    public String[] getTags() {
        if (articleTag != null) {
            String[] split = articleTag.split(",");
            return split;
        }
        return null;
    }

}
